﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using LowLevelGraphics;
using LowLevelGraphics.Filter;

namespace LowLevelGraphics.Filter
{
    /// <summary>
    /// For use refer also to halcon. I tried to do exactly the same.
    /// This is used to enhance spots, e.g. to use for prints created by a matrix printer
    /// </summary>
    public class DotsImage : BaseImageFilter
    {
        //circular mask
        int[,] aKernel = new int[,]
        {
                     {0,0, -21, -21, -21, 0,0},
                     {0,-21,  16,  16,  16, -21,0},
                     {-21,  16,  16,  16,  16,  16, -21},
                     {-21,  16,  16,  16,  16,  16, -21},
                     {-21,  16,  16,  16,  16,  16, -21},
                     {0,-21,  16,  16,  16, -21,0},
                     {0,0,-21, -21, -21,0,0 }
       };

        /// <summary>
        /// 
        /// </summary>
        public DotsImage()
        {
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="_dotsImage"></param>
        internal DotsImage(DotsImage _dotsImage)
        {
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="_bitmap"></param>
        /// <returns></returns>
        public override UnsafeBitmap Execute(UnsafeBitmap _bitmap)
        {
            OwnOptimizedConvolutionInt ownOptimizedConvolution = new OwnOptimizedConvolutionInt(aKernel);
            //ownOptimizedConvolution.Div = 336;
            ownOptimizedConvolution.Execute(_bitmap);
            return _bitmap;
        }

        /// <summary>
        /// Clones this instance
        /// </summary>
        /// <returns></returns>
        public override object Clone()
        {
            return new DotsImage(this);
        }
    }
}
